<?php
include("./config.php");
if ($_SERVER["REQUEST_METHOD"] == "POST") {
	$userNum = mysql_real_escape_string($_POST['UserNum']);
	$item1 = mysql_real_escape_string($_POST['Item1']);
	$item2 = mysql_real_escape_string($_POST['Item2']);
	$item3 = mysql_real_escape_string($_POST['Item3']);
	$cellStack = mysql_real_escape_string($_POST['CellStack']);

	$sql = "update USER_ITEM_TABLE set ItemNum='$item1' where UserNum=$userNum and ItemTableNum=1";	
	mysql_query($sql) or die(-1);

	$sql = "update USER_ITEM_TABLE set ItemNum='$item2' where UserNum=$userNum and ItemTableNum=2";	
	mysql_query($sql) or die(-1);
	
	$sql = "update USER_ITEM_TABLE set ItemNum='$item3' where UserNum=$userNum and ItemTableNum=3";	
	mysql_query($sql) or die(-1);

	$sql = "update user_info_table set CellStack=$cellStack where UserNum=$userNum";
	mysql_query($sql) or die(-1);

} else if ($_SERVER["REQUEST_METHOD"] == "GET") {
	$userNum = mysql_real_escape_string($_GET['UserNum']);
	$sql = "select * from USER_ITEM_TABLE where UserNum = $userNum";
	$arrQuery = mysql_query($sql);

	$count = mysql_num_rows($arrQuery);
	if($count == 0){
		echo 0;
		die();
	}

	$result = "";
	while($row = mysql_fetch_array($arrQuery)){
		$result .= $row['ItemNum']."$";
	}
	
	$result = substr($result,0,-1);
	echo $result;
}
?>